﻿using System;
using Xunit;

namespace LeRenard.Core.Tests._extensions_
{
    public class StringExtensionsTests
    {
        [Fact]
        public void RemoveMultipleWhitespaces_Returns_Correct_String()
        {
            // Arrange
            var expected = "This string is cleaned from whitespace overload.";
            var whitespaceOverload = "This            string is cleaned   from   whitespace overload.";
            var actual = String.Empty;

            // Act
            actual = whitespaceOverload.RemoveMultipleWhitespaces();

            // Assert
            Assert.Equal<string>(expected, actual);
        }

        [Fact]
        public void RemoveMultipleWhitespaces_Doesnt_Throw_Exception_On_Null_String()
        {
            // Arrange
            var expected = (Exception)null;
            var actual = (Exception)null;
            var nullString = (string)null;

            // Act            
            try
            {
                var whitespacesRemoved = nullString.RemoveMultipleWhitespaces();
            }
            catch (Exception ex)
            {
                actual = ex;
            }

            // Assert
            Assert.Equal<Exception>(expected, actual);
        }
    }
}
